/**
 * Standalone Express Application
 * for vercel serverless functions
 */

/* eslint-disable @typescript-eslint/no-var-requires */
import express from 'express'
import cors from 'cors'

const api = express()

api.use(express.json())
api.use(express.urlencoded({ extended: true }))
api.use(cors())

/*
app.request.can = function (role: Role) {
  return this.user != null && this.user.role >= role
}
*/
// endpoints
api.use('/menus', require('./menus').default)
api.use('/excel', require('./excel').default)
api.use('/levels', require('./levels').default)
api.use('/custom', require('./custom').default)
api.use('/dps/v1', require('./dps/v1').default)
api.use('/view', require('./view').default)

// 404 responses
api.use((req, res) => res.status(404).json({ message: 'Not Found' }))

export default api
